package simple.form.dao;

import java.util.*;

/**
 * Created by Administrator on 2017/3/1.
 */
public  class AbsDAO<T> {
    public static SqlExecutor sqlExecutor = MysqlExecutor.getInstance();

    public T findOne(String sql,Class beanClass){
        return (T) sqlExecutor.findOne(sql,beanClass);
    }
    public T findOne(T bean){
        return (T) sqlExecutor.findOne(bean);
    }
    /**
     * 通过sql获取结果集
     * @param sql,beanClass 返回结果entity类型
     * @return
     */
    public List<T> findAll(String sql,Class beanClass){
        return  sqlExecutor.findAll(sql,beanClass);

    }
    /**
     * 查询结果
     * @param bean
     * @return
     */
    public List<T> findAll(T bean){
        return sqlExecutor.findAll(bean);
    }

    /**
     * insert操作
     * @param bean
     * @return
     */
    protected int insert(T bean){
        return sqlExecutor.insert(bean);
    }

    /**
     * update操作
     * @param bean
     * @return
     */
    protected int updateByKey(T bean){
        return sqlExecutor.updateByKey(bean);
    }

    /**
     * delete操作
     * @param bean
     * @return
     */
    protected int delete(T bean){
        return  sqlExecutor.delete(bean);
    }
}
